package com.xiaoyu.izf.model;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import java.sql.Date;
import java.sql.Timestamp;
import java.util.Objects;

@Entity
@Table(name = "merchant_info", schema = "izf", catalog = "")
public class MerchantInfo {
    private int id;
    private String merchantName;
    private String merchantSimpleName;
    private String linkmanName;
    private String linkmanMobile;
    private String servicePhone;
    private String email;
    private String merchantTypeInfo;
    private String merchantAddress;
    private String legalPersonName;
    private String legalPersonMobile;
    private String legalPersonIdNumber;
    private Date legalPersonIdNumberStart;
    private Date legalPersonIdNumberEnd;
    private String businessLicenseNumber;
    private Date businessLicenseStart;
    private Date businessLicenseEnd;
    private Timestamp createTime;
    private Integer disabled;
    private Integer parUid;
    private String regionCode;
    private Double rateReturnCommission;

    private UserInfo parUser;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "merchant_name")
    public String getMerchantName() {
        return merchantName;
    }

    public void setMerchantName(String merchantName) {
        this.merchantName = merchantName;
    }

    @Basic
    @Column(name = "merchant_simple_name")
    public String getMerchantSimpleName() {
        return merchantSimpleName;
    }

    public void setMerchantSimpleName(String merchantSimpleName) {
        this.merchantSimpleName = merchantSimpleName;
    }

    @Basic
    @Column(name = "linkman_name")
    public String getLinkmanName() {
        return linkmanName;
    }

    public void setLinkmanName(String linkmanName) {
        this.linkmanName = linkmanName;
    }

    @Basic
    @Column(name = "linkman_mobile")
    public String getLinkmanMobile() {
        return linkmanMobile;
    }

    public void setLinkmanMobile(String linkmanMobile) {
        this.linkmanMobile = linkmanMobile;
    }

    @Basic
    @Column(name = "service_phone")
    public String getServicePhone() {
        return servicePhone;
    }

    public void setServicePhone(String servicePhone) {
        this.servicePhone = servicePhone;
    }

    @Basic
    @Column(name = "email")
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Basic
    @Column(name = "merchant_type_info")
    public String getMerchantTypeInfo() {
        return merchantTypeInfo;
    }

    public void setMerchantTypeInfo(String merchantTypeInfo) {
        this.merchantTypeInfo = merchantTypeInfo;
    }

    @Basic
    @Column(name = "merchant_address")
    public String getMerchantAddress() {
        return merchantAddress;
    }

    public void setMerchantAddress(String merchantAddress) {
        this.merchantAddress = merchantAddress;
    }

    @Basic
    @Column(name = "legal_person_name")
    public String getLegalPersonName() {
        return legalPersonName;
    }

    public void setLegalPersonName(String legalPersonName) {
        this.legalPersonName = legalPersonName;
    }

    @Basic
    @Column(name = "legal_person_mobile")
    public String getLegalPersonMobile() {
        return legalPersonMobile;
    }

    public void setLegalPersonMobile(String legalPersonMobile) {
        this.legalPersonMobile = legalPersonMobile;
    }

    @Basic
    @Column(name = "legal_person_id_number")
    public String getLegalPersonIdNumber() {
        return legalPersonIdNumber;
    }

    public void setLegalPersonIdNumber(String legalPersonIdNumber) {
        this.legalPersonIdNumber = legalPersonIdNumber;
    }

    @Basic
    @Column(name = "legal_person_id_number_start")
    public Date getLegalPersonIdNumberStart() {
        return legalPersonIdNumberStart;
    }

    public void setLegalPersonIdNumberStart(Date legalPersonIdNumberStart) {
        this.legalPersonIdNumberStart = legalPersonIdNumberStart;
    }

    @Basic
    @Column(name = "legal_person_id_number_end")
    public Date getLegalPersonIdNumberEnd() {
        return legalPersonIdNumberEnd;
    }

    public void setLegalPersonIdNumberEnd(Date legalPersonIdNumberEnd) {
        this.legalPersonIdNumberEnd = legalPersonIdNumberEnd;
    }

    @Basic
    @Column(name = "business_license_number")
    public String getBusinessLicenseNumber() {
        return businessLicenseNumber;
    }

    public void setBusinessLicenseNumber(String businessLicenseNumber) {
        this.businessLicenseNumber = businessLicenseNumber;
    }

    @Basic
    @Column(name = "business_license_start")
    public Date getBusinessLicenseStart() {
        return businessLicenseStart;
    }

    public void setBusinessLicenseStart(Date businessLicenseStart) {
        this.businessLicenseStart = businessLicenseStart;
    }

    @Basic
    @Column(name = "business_license_end")
    public Date getBusinessLicenseEnd() {
        return businessLicenseEnd;
    }

    public void setBusinessLicenseEnd(Date businessLicenseEnd) {
        this.businessLicenseEnd = businessLicenseEnd;
    }

    @Basic
    @Column(name = "create_time")
    public Timestamp getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    @Basic
    @Column(name = "disabled")
    public Integer getDisabled() {
        return disabled;
    }
    public void setDisabled(Integer disabled) {
        this.disabled = disabled;
    }

    @Basic
    @Column(name = "par_uid")
    public Integer getParUid() {
        return parUid;
    }

    public void setParUid(Integer parUid) {
        this.parUid = parUid;
    }

    @Basic
    @Column(name = "region_code")
    public String getRegionCode() {
        return regionCode;
    }
    public void setRegionCode(String regionCode) {
        this.regionCode = regionCode;
    }

    @Basic
    @Column(name = "rate_return_commission")
    public Double getRateReturnCommission() {
        return rateReturnCommission;
    }
    public void setRateReturnCommission(Double rateReturnCommission) {
        this.rateReturnCommission = rateReturnCommission;
    }

    @ManyToOne(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY, optional = true)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "par_uid", referencedColumnName = "id", insertable = false, updatable = false,foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
    public UserInfo getParUser() {
        return parUser;
    }
    public void setParUser(UserInfo parUser) {
        this.parUser = parUser;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        MerchantInfo that = (MerchantInfo) o;
        return id == that.id &&
                Objects.equals(merchantName, that.merchantName) &&
                Objects.equals(merchantSimpleName, that.merchantSimpleName) &&
                Objects.equals(linkmanName, that.linkmanName) &&
                Objects.equals(linkmanMobile, that.linkmanMobile) &&
                Objects.equals(servicePhone, that.servicePhone) &&
                Objects.equals(email, that.email) &&
                Objects.equals(merchantTypeInfo, that.merchantTypeInfo) &&
                Objects.equals(merchantAddress, that.merchantAddress) &&
                Objects.equals(legalPersonName, that.legalPersonName) &&
                Objects.equals(legalPersonMobile, that.legalPersonMobile) &&
                Objects.equals(legalPersonIdNumber, that.legalPersonIdNumber) &&
                Objects.equals(legalPersonIdNumberStart, that.legalPersonIdNumberStart) &&
                Objects.equals(legalPersonIdNumberEnd, that.legalPersonIdNumberEnd) &&
                Objects.equals(businessLicenseNumber, that.businessLicenseNumber) &&
                Objects.equals(businessLicenseStart, that.businessLicenseStart) &&
                Objects.equals(businessLicenseEnd, that.businessLicenseEnd);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, merchantName, merchantSimpleName, linkmanName, linkmanMobile, servicePhone, email, merchantTypeInfo, merchantAddress, legalPersonName, legalPersonMobile, legalPersonIdNumber, legalPersonIdNumberStart, legalPersonIdNumberEnd, businessLicenseNumber, businessLicenseStart, businessLicenseEnd);
    }

    @Override
    public String toString() {
        return "MerchantInfo{" +
                "id=" + id +
                ", merchantName='" + merchantName + '\'' +
                ", merchantSimpleName='" + merchantSimpleName + '\'' +
                ", linkmanName='" + linkmanName + '\'' +
                ", linkmanMobile='" + linkmanMobile + '\'' +
                ", servicePhone='" + servicePhone + '\'' +
                ", email='" + email + '\'' +
                ", merchantTypeInfo='" + merchantTypeInfo + '\'' +
                ", merchantAddress='" + merchantAddress + '\'' +
                ", legalPersonName='" + legalPersonName + '\'' +
                ", legalPersonMobile='" + legalPersonMobile + '\'' +
                ", legalPersonIdNumber='" + legalPersonIdNumber + '\'' +
                ", legalPersonIdNumberStart=" + legalPersonIdNumberStart +
                ", legalPersonIdNumberEnd=" + legalPersonIdNumberEnd +
                ", businessLicenseNumber='" + businessLicenseNumber + '\'' +
                ", businessLicenseStart=" + businessLicenseStart +
                ", businessLicenseEnd=" + businessLicenseEnd +
                ", createTime=" + createTime +
                ", disabled=" + disabled +
                ", parUid=" + parUid +
                ", regionCode='" + regionCode + '\'' +
                ", parUser=" + parUser +
                '}';
    }
}
